// pages/my/my.js
var httpTool = require('../..//utils/network.js');
var util = require('../../utils/util.js')
const app = getApp()
Page({
  data:{
    vacation:'',//圆满假期信息
    enroll: '',//报名信息
  },
  //报名详情
  toSignUpDetails: function () {
    util.navigateTo('../signupdetails/signupdetails');
  },
   //确认签收
  toConfirmSign: function (event) {
    var task = event.currentTarget.dataset.model;
    console.log(task);
    util.navigateTo('../signconfirm/signconfirm?taskId=' + task.id + '&vacationId=' + task.vacationId);
  },
  //去签收
  toSign: function (event) {
    var task = event.currentTarget.dataset.model;
    console.log(task);
    util.navigateTo('../signcode/signcode?taskId=' + task.id + '&vacationId=' + task.vacationId);
  },
  // 去做任务
  toDoTask: function() {
    util.navigateTo('../finishtask/finishtask');
  },
  //实践证明
  toPractice: function () {
    util.navigateTo('../practiceprove/practiceprove');
  },
  // 受助者签收记录
  toSignRecord: function () {
    util.navigateTo('../signrecord/signrecord');
  },
  //我的动态
  toMyFeed: function () {
    util.navigateTo('../myfeed/myfeed');
  },
  onLoad:function(options){
    // 生命周期函数--监听页面加载
    //获得圆满假期信息
    this.getVacationInfo();
  },
  //获得圆满假期信息
  getVacationInfo: function () {
    var that = this;
    var url = app.data.httpUrl + 'v1/vacation/getVacationInfoWithTasks'
    var param = {
      id: app.globalData.vacationId,//圆满假期ID
      memberId: app.userData.userId,
    }
    httpTool.sendRequest(url, param, '', function (res) {
      that.setData({
        vacation: res.entity,
        enroll: res.entity.enroll,
      })
      console.log("getVacationInfo:");
      console.log(res.entity)
    }, function (error) {
      console.log("加载圆满假期详情异常:", error);
    })
  },
  onReady:function(){
    // 生命周期函数--监听页面初次渲染完成
    
  },
  onShow:function(){
    // 生命周期函数--监听页面显示
    
  },
  onHide:function(){
    // 生命周期函数--监听页面隐藏
    
  },
  onUnload:function(){
    // 生命周期函数--监听页面卸载
    
  },
  onPullDownRefresh: function() {
    // 页面相关事件处理函数--监听用户下拉动作
    
  },
  onReachBottom: function() {
    // 页面上拉触底事件的处理函数
    
  },
  onShareAppMessage: function() {
    // 用户点击右上角分享
    return {
      title: 'title', // 分享标题
      desc: 'desc', // 分享描述
      path: 'path' // 分享路径
    }
  }
})
